home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 23 / AACD 23.iso / AACD / Programming / tek / visual / allocpen.c next >
C/C++ Source or Header  |  2001-05-25  |  744b  |  40 lines

  1.  
  2. #include "tek/visual.h"
  3. #include "tek/debug.h"
  4. #include "tek/kn/visual.h"
  5.  
  6. /* 
  7. **    TEKlib
  8. **    (C) 2001 TEK neoscientists
  9. **    all rights reserved.
  10. **
  11. **    TVPEN pen = TVAllocPen(TAPTR visual, TUINT rgb)
  12. **
  13. **    alloc pen.
  14. */
  15.  
  16. TVPEN TVAllocPen(TAPTR visual, TUINT rgb)
  17. {
  18.     TVISUAL *v = (TVISUAL *) visual;
  19.     TDRAWMSG *msg;
  20.     TVPEN ret;
  21.  
  22.     for (;;)
  23.     {
  24.         if ((msg = TGetMsg(v->asyncport)))
  25.         {
  26.             msg->jobcode = TVJOB_ALLOCPEN;
  27.             msg->op.rgbpen.rgb = rgb;
  28.  
  29.             TSendMsg(v->parenttask, TTaskPort(v->task), msg);            
  30.  
  31.             kn_lock(&v->asyncport->lock);
  32.             TAddTail(&v->asyncport->msglist, (TNODE *) (((TMSG *) msg) - 1));
  33.             ret = msg->op.rgbpen.pen;
  34.             kn_unlock(&v->asyncport->lock);
  35.             return ret;
  36.         }
  37.         TWaitPort(v->asyncport);        /* wait for free node */
  38.     }
  39. }
  40.